﻿/**
 * 大廳頂部按鈕
 * 
 * @author luo
 * @email luo4521@online.net.tw
 * 2010-2-6 12:09
 */
package com.addcn.texas.view.components
{
	import flash.display.MovieClip;
	import flash.events.*;
	import flash.text.TextField;	
	
	import com.addcn.common.event.ParamEvent;	
	
	public class TopMenu extends winBase
	{		
		public static const EVENT : String = 'clickEvent';		
		
		function TopMenu ( ) : void {	
			_initilize();
		}		
		private function _initilize() : void
		{
			this["Button0"].addEventListener(MouseEvent.CLICK, buttonClickHandler);
			this["Button1"].addEventListener(MouseEvent.CLICK, buttonClickHandler);
			this["Button2"].addEventListener(MouseEvent.CLICK, buttonClickHandler);
			this["Button3"].addEventListener(MouseEvent.CLICK, buttonClickHandler);
			this["Button4"].addEventListener(MouseEvent.CLICK, quickInClickHandler);			
			this["Refresh"].addEventListener(MouseEvent.CLICK, refreshClickHandler);
		}
		private function buttonClickHandler(evt : Event) : void
		{
			var _type : String = evt.currentTarget.name.substr( -1, 1);
			var _event = new ParamEvent(TopMenu.EVENT, { type:_type } );
			this.dispatchEvent(_event);
		}
		
		public function setButtonTxt(r_arr : Array) : void
		{
			if(r_arr.length >0 ){
				this["Button0"]["txt"].text = String(r_arr[0]);
				this["Button1"]["txt"].text = String(r_arr[1]);
				this["Button2"]["txt"].text = String(r_arr[2]);
				this["Button3"]["txt"].text = String(r_arr[3]);				
			}
		}
		
		private function quickInClickHandler(evt : Event) : void
		{
			
		}
		
		private function refreshClickHandler(evt : Event) : void
		{
			var _event = new ParamEvent(TopMenu.EVENT, { request:true} );
			this.dispatchEvent(_event);
		}
		
		public function clear() : void
		{
			this["Button0"].removeEventListener(MouseEvent.CLICK, buttonClickHandler);
			this["Button1"].removeEventListener(MouseEvent.CLICK, buttonClickHandler);
			this["Button2"].removeEventListener(MouseEvent.CLICK, buttonClickHandler);
			this["Button3"].removeEventListener(MouseEvent.CLICK, buttonClickHandler);
			this["Button4"].removeEventListener(MouseEvent.CLICK, quickInClickHandler);			
			this["Refresh"].removeEventListener(MouseEvent.CLICK, refreshClickHandler);
		}
		
		
	}
	
}
